package com.example.testdemo.list_single_select;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ListView;

import com.example.testdemo.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 颜 on 04.11.011.
 * ListView单选
 */

public class ListViewSingleSelect extends Activity {
    private ListView listView;
    private List<String> listData;
    private MyListAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_single);
        initView();
        initData();
    }

    private void initData() {
        listData = new ArrayList<>();
        listData.add("家具");
        listData.add("家电");
        listData.add("床上用品");
        listData.add("厨卫");
        listData.add("家装");
        listData.add("电子产品");
        listData.add("数码");
        listData.add("手机");
        listData.add("电脑");
        listData.add("男装");
        listData.add("女装");
        adapter = new MyListAdapter(this,listData);
        listView.setAdapter(adapter);
        adapter.notifyDataSetChanged();
    }

    private void initView() {
        listView = findViewById(R.id.listView);

    }
}
